<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<h:body>
	<ui:composition template="/template.xhtml">
		<ui:define name="corpo">
		
		<h:form id="frmTabela">
			<p:dataTable id="tblTodasRespostas" paginator="true" paginatorAlwaysVisible="false" var="respondidas" value="#{duvidaBean.respondidas}" emptyMessage="Nenhum registro encontrado">
				<f:facet name="header">Dúvidas respondidas</f:facet>

				<p:column headerText="Titulo">
					<h:outputText value="#{respondidas.titulo}" style="text-align:center;" />
				</p:column>
				
				<p:column headerText="Professor">
					<h:outputText value="#{respondidas.professor.nome}" />
				</p:column>
				
				<p:column headerText="Titulo">
					<h:outputText value="#{respondidas.data}">
						<f:convertDateTime pattern="dd/MM/yyyy"/>
					</h:outputText>
				</p:column>
				
				<p:column headerText="Visualizar" style="width:4%">
					
					<p:commandButton value="Visualizar" oncomplete="dlgExibirPergunta.show()" update=":formDialog:painelDialog">
						<f:setPropertyActionListener target="#{duvidaBean.duvidaTemp}" value="#{respondidas}"/>
					</p:commandButton>
					
				</p:column>
			</p:dataTable>
		</h:form>
		
		<h:form id="formDialog">
			<p:dialog id="dlgExibir" header="Duvida" widgetVar="dlgExibirPergunta">				
					<p:panelGrid columns="2" id="painelDialog">
						<h:outputLabel value="Assunto:" />
						<h:outputText value="#{duvidaBean.duvidaTemp.titulo}" />
						
						<h:outputLabel value="Descricao"/>
						<h:outputText value="#{duvidaBean.duvidaTemp.descricao}" escape="false"/>
						
						<h:outputLabel value="Autor:"/>
						<h:outputText value="#{duvidaBean.duvidaTemp.professor.nome}" />
						
						<h:outputLabel value="Resposta:"/>
						<p:editor value="#{duvidaBean.duvidaTemp.resposta.resposta}" disabled="true"/>
					</p:panelGrid>				
			</p:dialog>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>